package com.antunnel.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.antunnel.common.orm.BaseServiceImpl;
import com.antunnel.system.dao.UserBaseDao;
import com.antunnel.system.entity.UserBase;
import com.antunnel.system.service.UserBaseService;

@Service
public class UserBaseServiceImpl extends BaseServiceImpl implements UserBaseService{

	@Autowired
	private UserBaseDao userBaseDao;
	
	/**
	 * 根据用户名密码查询user对象
	 * @param loginCode 登录名
	 * @param loginPsw 登录密码
	 * @return 
	 * @throws Exception
	 */
	public UserBase loadUserByUserNameAndPsw(String loginCode,String loginPsw) throws Exception{
		List<UserBase> userList=userBaseDao.loadUserByUserNameAndPsw(loginCode, loginPsw);
		if(userList!=null && userList.size()>0){
			return userList.get(0);
		}else{
			return null;
		}
	}

	/**
	 * 根据绑定的邮箱 ，绑定的银行，账号，开户人姓名查找用户
	 * @param email
	 * @param bankname 银行名称
	 * @param banknumber 银行卡号
	 * @param bankuser 所持账户姓名
	 * @param username 用户名
	 * @return
	 * @throws Exception
	 */
	public UserBase loadUserByMsg(String email, String banknumber,String bankname,
			String bankuser, String username) throws Exception {
		List<UserBase> userList=userBaseDao.loadUserByMsg(email,banknumber,bankname,bankuser,username);
		if(userList!=null && userList.size()>0){
			return userList.get(0);
		}else{
			return null;
		}
	}
}
